class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-10-08",
      revision: "794d9e4342d3a16b8e7adb8c395a5705a0b427b2"
  version "2021-10-08"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "80d3ae36b791fc31189b77d546208384236e0dc90e7f69d1a26e516b1cb77c91"
    sha256 cellar: :any_skip_relocation, big_sur:       "6213f7916fc5c2e5db5a8765902391cbe0fbdcb63dc0f957a202f6be10d6b305"
    sha256 cellar: :any_skip_relocation, catalina:      "aa1d49bbfc9140a33ef406ad7ff1a6a3268bb12f86d8a9da169577e055c2356c"
    sha256 cellar: :any_skip_relocation, mojave:        "ce7b633bcec792e07c95548da1c7953c58c74c92b78f9fef2dec3174a67c43d4"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "643b633a941ca529475edecd61ceb70f7ad95ee92066fc15837c5426043e4274"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
